fix: prevent update root role in DomainPermissionHandler#984
Conversation
WalkthroughA conditional check was added to the Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
packages/hydrooj/src/handler/domain.tsOops! Something went wrong! :( ESLint: 9.27.0 Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@hydrooj/eslint-config' imported from /eslint.config.mjs ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/hydrooj/src/handler/domain.ts (1)
217-217: Excellent security fix!This change properly prevents the 'root' role from being modified through the permission endpoint, which is a critical security measure. The implementation is clean, well-commented, and follows the existing pattern seen in other parts of the code (like the role deletion protection on lines 256-258).
Consider applying similar protection for other system roles like 'default' and 'guest' if they shouldn't be modifiable through this endpoint:
for (const role in this.request.body) { - if (role === 'root') continue; // root role is not editable + if (['root', 'default', 'guest'].includes(role)) continue; // system roles are not editableThis would provide consistent protection across all system roles.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/hydrooj/src/handler/domain.ts(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: build
Summary by CodeRabbit